//全排列 力扣46
//回溯算法 index控制每一层的遍历范围或遍历规则
class Solution {
public:
	void backtracking(vector<int>& st,vector<int>& nums,vector<int>& path,vector<vector<int>>& ans)
	{
		if(path.size() == nums.size())
		{
			ans.push_back(path);
			return ;
		}
		for(int i = 0; i < nums.size(); i++)
		{
			if(st[i] != 1)
			{
				path.push_back(nums[i]);
				st[i] = 1;
				backtracking(st,nums,path,ans);
				path.pop_back();
				st[i] = 0;
			}  
		}
	}
	vector<vector<int>> permute(vector<int>& nums) {
		vector<int> path;
		vector<vector<int>> ans;
		vector<int> st(nums.size(),0);
		backtracking(st,nums,path,ans);
		return ans;
	}
};
